<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>异步请求工程</h1>
<div>
    <input type="button" value="异步Get请求" @click="f1()">
    <input type="button" value="异步Post请求" @click="f2()">
    <a href="/bmi.html">BMI测试</a>
    <hr>
    <a href="/reg.html">注册</a>
    <a href="/login.html">登录</a>
</div>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<script>
  let v = new Vue({
    el:"body>div",
    data:{

    },
    methods:{
      f1(){
          //发出异步Get请求
          // axios.get("/helloAxios").then(function (response) {
          //     //response代表响应，里面装这服务器响应的数据
          //     alert(response.data)
          // })
          axios.get("/p1?name=蔡徐坤&age=26").then(function (response) {
              alert(response.data);
          })

      },
      f2(){
          // axios.post("/helloAxios").then(function (response) {
          //     alert(response.data);
          // })
          let p={title:"坤坤签名手机壳",price:"35",num:"100"}
          axios.post("/p2",p).then(function (response) {
              alert(response.data);
          })
      }
    }
  })
</script>
</body>
</html>